package com.sskj.hhrt.transaction;

import com.sskj.base.utils.RxUtils;
import com.sskj.hhrt.BasePresenter;
import com.sskj.hhrt.api.Api;
import com.sskj.hhrt.api.ApiObserver;
import com.sskj.hhrt.transaction.data.OrderHistoryBean;

import java.util.ArrayList;
import java.util.List;

public class DealPresenter extends BasePresenter<DealFragment> {
    public void getTodayEntrust(String account, int page, int pageSize) {
        Api.getInstance().todayDeal(page, pageSize)
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<List<OrderHistoryBean.OrderHistory>>(this, true) {
                    @Override
                    public void onSuccess(List<OrderHistoryBean.OrderHistory> data) {
                        mView.setData(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        mView.hideLoading();
                        List list = new ArrayList<OrderHistoryBean.OrderHistory>();
                        mView.setData(list);
                        mView.finishRefresh();
                    }

                    @Override
                    public void onComplete() {
                        super.onComplete();
                        mView.finishRefresh();
                    }
                });
    }
}
